package com.hfi.service;

import com.hfi.mapper.EmployeeMapper;
import com.hfi.mapper.EmployeeMapperDynamicSQL;
import com.hfi.mapper.EmployeeMapperPlus;
import com.hfi.model.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author ChangLiang
 * @date 2019/5/22
 */
@Service
public class EmployeeService {


    @Autowired
    private EmployeeMapper employeeMapper;

    @Autowired
    private EmployeeMapperPlus employeeMapperPlus;

    @Autowired
    private EmployeeMapperDynamicSQL employeeMapperDynamicSQL;

    public Employee getEmployeeById(Integer id) {

        Employee employee = employeeMapper.getEmployeeById(id);
        System.out.println(employee);

        Employee employee1 = employeeMapper.getEmployeeById(id);
        System.out.println(employee==employee1);

        return employee;
    }

    public Map<String, Employee> getEmpByLastNameLikeReturnMap(String lastName) {
        Map<String, Employee> map = employeeMapper.getEmpByLastNameLikeReturnMap(lastName);
        System.out.println(map);
        return map;
    }

    public Employee getEmpByIdByStep(Integer id) {
        Employee employee = employeeMapperPlus.getEmpByIdByStep(id);
        System.out.println(employee);
        return employee;
    }

    public List<Employee> getEmpsByConditionIf(Employee employee) {
        List<Employee> employees = employeeMapperDynamicSQL.getEmpsByConditionIf(employee);
        System.out.println(employees);
        return employees;
    }

    public void addEmps(List<Employee> emps) {
        employeeMapperDynamicSQL.addEmps(emps);
    }

    public Long addEmp(Employee employee) {
        return employeeMapper.addEmp(employee);
    }
}
